clear; clc;
dataset = 'movielen1m';
load(strcat('../noncvx-lowrank/data/recsys/', dataset, '.mat'));

[row, col, val] = find(data);
idx = randperm(length(val));

traIdx = idx(1:floor(length(val)*0.5));
tstIdx = idx(ceil(length(val)*0.5): end);

clear idx;

traData = sparse(row(traIdx), col(traIdx), val(traIdx));
traData(size(data,1), size(data,2)) = 0;

lambdaMax = topksvd(traData, 1, 5);
gradLambda = lambdaMax*(0.6).^(1:15);

para.maxIter = 5000;
para.decay = 0.8;

%% start testing
switch (dataset)
    case 'movielen100k'
        lambda = 8.9;
        para.tol = 1e-5;
        
        para.maxR = 150;
    case 'movielen1m'
        lambda = 16.5;
        para.tol = 1e-3;
        
        para.maxR = 400;
    case 'movielen10m'
        lambda = 45;
        
        para.tol = 1e-2;
        para.maxR = 300;
end

[U, S, V, out] = AccSoftImpute( traData', lambda, para );
 
close all;
plot(out.RankIn);
hold on;
plot(out.RankOut);
